<?php
function hienthi($gh)
  {
	 ?>
     <table border="1" cellspacing=0><tr><td>STT</td><td>Ma dh</td>
        <td>Tendh</td><td>Gia</td><td>SL</td><td>TT</td></tr>   
    	<?php
		$i=0; $tong=0;
		foreach($gh as $m =>$sl)
		{	$i++;
			$sql ="select * from dongho where madh='$m' ";
			$kq = mysql_query($sql);
			if (mysql_num_rows($kq)>0)
			{
				$r =mysql_fetch_array($kq);
				$t = $r["tendh"]; $g = $r['gia'];
				echo "<tr><td>$i</td><td>$m</td>";
				echo "<td>$t</td><td>$g</td>";
				$tt = $g*$sl;  $tong +=$tt;
				echo "<td>$sl</td>";
				echo "<td>$tt</td></tr>";
			}
		}
		echo "<tr><td colspan=5>Tong so tien</td><td>$tong</td></tr>";
		echo "</table>";
	 }



if (!isset($_SESSION)) session_start();
if (!isset($_SESSION['email']))  {    echo "Khang can dang nhap de mua hang"; echo "<b><a href=dangnhap.php>dang Nhap</a></b>"; exit;}

if (!isset($_SESSION["giohang"]))
	{
		echo "Khang can chon SP de mua hang. "; echo "&nbsp; <a href=sanpham.php>Xem hang</a>"; exit;
	}
$giohang = $_SESSION['giohang'];
if (count($giohang)==0)
{
	echo "KHang can chon SP de mua hang. "; echo "&nbsp; <a href=sanpham.php>Xem hang</a>"; exit;
	
}

$email = $_SESSION["email"];
include_once("connect.php");
$sql = "select * from khachhang where email ='$email' ";
$kq = mysql_query($sql);
if (mysql_num_rows($kq)==0) exit;
$r = mysql_fetch_array($kq);
$tkh = $r['tenkh'];
$dc = $r["diachi"];
$dt = $r['dienthoai'];
?>
<style>
.div1 {-moz-border-radius: 5px; -webkit-border-radius: 5px; border: 1px solid #CCCCCC; 
padding: 10px; background:#af012; width:700px; left:191px; background-color:#CFC; margin:20px}
</style>
<?php
//MX Widgets3 include
require_once('includes/wdg/WDG.php');
?>
<script src="includes/common/js/base.js" type="text/javascript"></script>
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<script type="text/javascript" src="includes/wdg/classes/MXWidgets.js"></script>
<script type="text/javascript" src="includes/wdg/classes/MXWidgets.js.php"></script>
<script type="text/javascript" src="includes/wdg/classes/Calendar.js"></script>
<script type="text/javascript" src="includes/wdg/classes/SmartDate.js"></script>
<script type="text/javascript" src="includes/wdg/calendar/calendar_stripped.js"></script>
<script type="text/javascript" src="includes/wdg/calendar/calendar-setup_stripped.js"></script>
<script src="includes/resources/calendar.js"></script>

<link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />


<!--
Hien nthi thong tin khach hang dang nhap

-->
<div class='div1'>
	<table>
		<tr><td conspan=2>Thong tin Khach hang </td></tr>
		<tr><td>Email</td><td><?php echo $email; ?></td></tr>
		<tr><td>Ho ten</td><td><?php echo $tkh; ?></td></tr>
		<tr><td>Dien Thoai</td><td><?php echo $dt; ?></td></tr>
	</table>
</div>

<!--
Hien thi Form nhap thong tin cho khach hang nhan. (Se luu trong table don hang)
-->
<div class="div1">
	<form action=xulydonhang.php method=post>
		<table>
			<tr><td colspan=2> Thong tin nguoi nhan</td></tr>
			<tr><td>Ten Nguoi nhan</td><td><input type=text name=tennguoinhan></td></tr>
			<tr><td>Dia Chi Nguoi nhan</td><td><input type=text name=diachinguoinhan></td></tr>
			<tr><td>Dien Thoai Nguoi nhan</td><td><input type=text name=dienthoainguoinhan></td></tr>
			<tr><td>Ngay Nhan</td><td>
			<input name="ngaynhan" id="ngaynhan" value="" size = "20" wdg:subtype="Calendar" wdg:mask="<?php echo $KT_screen_date_format; ?>" wdg:type="widget" wdg:mondayfirst="true" wdg:singleclick="false" wdg:restricttomask="no" wdg:readonly="true"> 
			
			</td></tr>
			<tr><td colspan=2><input type=submit value="Thuc Hien"></td><tr>
		</table>
	</form>
</div>

<!--
Thong tin gio hang ma khach hang da chon
-->
<div class="div1">
Thong tin don hang
<?php
hienthi($giohang);
?>
</div>
